import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BookingOrderDetailApi } from '#/api/spa/booking/orderdetail';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

import {DICT_SPA_TYPE} from "#/utils/dictSpa";
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'bookingOrderId',
      label: '预约订单ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预约订单ID',
      },
    },
    {
      fieldName: 'detailCode',
      label: '明细编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入明细编码',
      },
    },
    {
      fieldName: 'sequenceNo',
      label: '明细序号',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入明细序号',
      },
    },
    {
      fieldName: 'itemType',
      label: '商品类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择商品类型',
      },
    },
    {
      fieldName: 'itemId',
      label: '商品ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入商品ID',
      },
    },
    {
      fieldName: 'itemName',
      label: '商品名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入商品名称',
      },
    },
    {
      fieldName: 'itemCode',
      label: '商品编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入商品编码',
      },
    },
    {
      fieldName: 'itemCategory',
      label: '商品分类',
      component: 'Input',
      componentProps: {
        placeholder: '请输入商品分类',
      },
    },
    {
      fieldName: 'quantity',
      label: '预约数量',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预约数量',
      },
    },
    {
      fieldName: 'estimatedUnitPrice',
      label: '预估单价',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估单价',
      },
    },
    {
      fieldName: 'estimatedTotalAmount',
      label: '预估总金额',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估总金额',
      },
    },
    {
      fieldName: 'estimatedDiscountRate',
      label: '预估折扣率(%)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估折扣率(%)',
      },
    },
    {
      fieldName: 'estimatedDiscountAmount',
      label: '预估折扣金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估折扣金额',
      },
    },
    {
      fieldName: 'estimatedFinalAmount',
      label: '预估最终金额',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估最终金额',
      },
    },
    {
      fieldName: 'estimatedDurationMinutes',
      label: '预估时长(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估时长(分钟)',
      },
    },
    {
      fieldName: 'detailStatus',
      label: '明细状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'specialRequirements',
      label: '特殊需求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入特殊需求',
      },
    },
    {
      fieldName: 'detailNotes',
      label: '明细备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入明细备注',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'bookingOrderId',
      label: '预约订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预约订单ID',
      },
    },
    {
      fieldName: 'detailCode',
      label: '明细编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入明细编码',
      },
    },
    {
      fieldName: 'sequenceNo',
      label: '明细序号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入明细序号',
      },
    },
    {
      fieldName: 'itemType',
      label: '商品类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择商品类型',
      },
    },
    {
      fieldName: 'itemId',
      label: '商品ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入商品ID',
      },
    },
    {
      fieldName: 'itemName',
      label: '商品名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入商品名称',
      },
    },
    {
      fieldName: 'itemCode',
      label: '商品编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入商品编码',
      },
    },
    {
      fieldName: 'itemCategory',
      label: '商品分类',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入商品分类',
      },
    },
    {
      fieldName: 'quantity',
      label: '预约数量',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预约数量',
      },
    },
    {
      fieldName: 'estimatedUnitPrice',
      label: '预估单价',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估单价',
      },
    },
    {
      fieldName: 'estimatedTotalAmount',
      label: '预估总金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估总金额',
      },
    },
    {
      fieldName: 'estimatedDiscountRate',
      label: '预估折扣率(%)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估折扣率(%)',
      },
    },
    {
      fieldName: 'estimatedDiscountAmount',
      label: '预估折扣金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估折扣金额',
      },
    },
    {
      fieldName: 'estimatedFinalAmount',
      label: '预估最终金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估最终金额',
      },
    },
    {
      fieldName: 'estimatedDurationMinutes',
      label: '预估时长(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估时长(分钟)',
      },
    },
    {
      fieldName: 'detailStatus',
      label: '明细状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择明细状态',
      },
    },
    {
      fieldName: 'specialRequirements',
      label: '特殊需求',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入特殊需求',
      },
    },
    {
      fieldName: 'detailNotes',
      label: '明细备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入明细备注',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BookingOrderDetailApi.BookingOrderDetail>['columns'] {
  return [
    {
      field: 'id',
      title: '订单明细ID',
      minWidth: 120,

    },
    {
      field: 'bookingOrderId',
      title: '预约订单ID',
      minWidth: 120,

    },
    {
      field: 'detailCode',
      title: '明细编码',
      minWidth: 120,

    },
    {
      field: 'sequenceNo',
      title: '明细序号',
      minWidth: 120,

    },
    {
      field: 'itemType',
      title: '商品类型',
      minWidth: 120,

    },
    {
      field: 'itemId',
      title: '商品ID',
      minWidth: 120,

    },
    {
      field: 'itemName',
      title: '商品名称',
      minWidth: 120,

    },
    {
      field: 'itemCode',
      title: '商品编码',
      minWidth: 120,

    },
    {
      field: 'itemCategory',
      title: '商品分类',
      minWidth: 120,

    },
    {
      field: 'quantity',
      title: '预约数量',
      minWidth: 120,

    },
    {
      field: 'estimatedUnitPrice',
      title: '预估单价',
      minWidth: 120,

    },
    {
      field: 'estimatedTotalAmount',
      title: '预估总金额',
      minWidth: 120,

    },
    {
      field: 'estimatedDiscountRate',
      title: '预估折扣率(%)',
      minWidth: 120,

    },
    {
      field: 'estimatedDiscountAmount',
      title: '预估折扣金额',
      minWidth: 120,

    },
    {
      field: 'estimatedFinalAmount',
      title: '预估最终金额',
      minWidth: 120,

    },
    {
      field: 'estimatedDurationMinutes',
      title: '预估时长(分钟)',
      minWidth: 120,

    },
    {
      field: 'detailStatus',
      title: '明细状态',
      minWidth: 120,

    },
    {
      field: 'specialRequirements',
      title: '特殊需求',
      minWidth: 120,

    },
    {
      field: 'detailNotes',
      title: '明细备注',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

